package station;

public class TimerThread implements Runnable {

	private SenderThread st;
	private volatile boolean running;
	
	public TimerThread(SenderThread st) {
		this.st = st;
		running = true;
	}

	public void run() {
		
		while(running){			
			try {
				Thread.sleep(1000 - (System.currentTimeMillis() % 1000));		//Bis zur vollen gesetzlichen Sekunde sleep
			} catch (InterruptedException e1) {
				e1.printStackTrace();
			}
			st.resetSlots();
			//System.out.println("TimerThread Zeit, wo resetSlots() aufgerufen wurde: " + System.currentTimeMillis());		
		}
	}//run
	
	public void terminate(){
		this.running = false;
		System.out.println("TimerThread...");
	}

}
